{
    var oHead = document.querySelector('.head')
    var oA = document.querySelector('.head .right a')
    var oZhuce = document.querySelector('.zhuce')
    var aInp = oZhuce.querySelectorAll('input')
    var oLogin = oZhuce.querySelector('.zhuce input[type=button]')
    oZhuce.onclick = function (e) {
        if (e.target.className === 'exit') {
            oZhuce.style.display = 'none'
        } 
    }
    oA.onclick = function() {
            oZhuce.style.display = "block"
            return false
        }
        
    var arr = [
        {
            re: /^1[3-9]\d{9}$/,
            succTxt: '',
            flag: false
        },
        {
            re: /^\w{6,16}$/,
            succTxt: '',
            flag: false
        },
    ]
    
    arr.forEach(function (ele, index) {
        aInp[index].addEventListener('input', function () {
            if (arr[index].re.test(this.value)) {       
                aInp[index].nextElementSibling.innerHTML = arr[index].succTxt
                arr[index].flag = true
            } else {        
                aInp[index].nextElementSibling.innerHTML = arr[index].errTxt
                arr[index].flag = false
            }
        })
    })
    
    oLogin.addEventListener('click', function () {
      
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].flag === false) {
                return
            }
        }
        alert('注册成功')
        location.href = 'http://localhost/wjj/index.html'
    })
}
{
    // 注册
    const oPhone = document.querySelector('.zhuce input[type=text]')
    const oVerifyCode = document.querySelector('.zhuce input[type=tel]')
    const oRegister = document.querySelector('.zhuce input[type=button]')

    oRegister.onclick = function () {
        if (/^1[3-9]\d{9}$/.test(oPhone.value) && /^\d{4}$/.test(oVerifyCode.value)) {
            // ajax
            ajax({
                url: 'http://192.168.10.28:8080/qfUser/register',
                type: 'post',
                data: {
                    username: oPhone.value,
                    password: oVerifyCode.value
                }
            })
        } 
    }
}
